package com.zch.enum_;

/**
 * Enum成员方法
 */
public class EnumMethod {
    public static void main(String[] args) {
        Season2 autumn = Season2.AUTUMN;
        System.out.println(autumn.name());
        System.out.println(autumn.ordinal()); //输出AUTUMN在该枚举类的次序编号

        System.out.println("===================");
        Season2[] values = Season2.values();
        for (Season2 season : values) {
            System.out.println(season.name());
        }

        System.out.println("===================");
        Season2 autumn1 = Season2.valueOf("AUTUMN"); //判断是否在枚举类中，如果有则返回对象
        System.out.println(autumn1 == autumn);

        System.out.println("===================");
        System.out.println(Season2.AUTUMN.compareTo(Season2.SUMMER)); //返回AUTUMN的次序编号-SUMMER的次序编号
    }
}
